//
//  UIView+MHFrame.h
//  MHDevLibExample
//
//  Created by apple on 16/5/12.
//  Copyright © 2016年 Mike_He. All rights reserved.
//
/**
 *  Mike_He
 *  这个分类主要用来  快速获得或者添加 控件的尺寸 ....
 */

#import <UIKit/UIKit.h>

@interface UIView (MHFrame)

/// < Shortcut for frame.origin.x.
@property (nonatomic, readwrite, assign) CGFloat mh_left;
/// < Shortcut for frame.origin.y
@property (nonatomic, readwrite, assign) CGFloat mh_top;
/// < Shortcut for frame.origin.x + frame.size.width
@property (nonatomic, readwrite, assign) CGFloat mh_right;
/// < Shortcut for frame.origin.y + frame.size.height
@property (nonatomic, readwrite, assign) CGFloat mh_bottom;

/// < Shortcut for frame.origin.x.
@property (nonatomic, readwrite, assign) CGFloat mh_x;
/// < Shortcut for frame.origin.y
@property (nonatomic, readwrite, assign) CGFloat mh_y;
/// < Shortcut for frame.size.width
@property (nonatomic, readwrite, assign) CGFloat mh_width;
/// < Shortcut for frame.size.height
@property (nonatomic, readwrite, assign) CGFloat mh_height;

/// < Shortcut for center.x
@property (nonatomic, readwrite, assign) CGFloat mh_centerX;
///< Shortcut for center.y
@property (nonatomic, readwrite, assign) CGFloat mh_centerY;

/// < Shortcut for frame.size.
@property (nonatomic, readwrite, assign) CGSize mh_size;
/// < Shortcut for frame.origin.
@property (nonatomic, readwrite, assign) CGPoint mh_origin;



@property (nonatomic) CGFloat mdh_x;            ///<< frame.x
@property (nonatomic) CGFloat mdh_y;            ///<< frame.y
@property (nonatomic) CGFloat mdh_w;            ///<< frame.size.width
@property (nonatomic) CGFloat mdh_h;            ///<< frame.size.height

@property (nonatomic) CGFloat mdh_r;            ///<< right
@property (nonatomic) CGFloat mdh_b;            ///<< bottom


@property (nonatomic) CGFloat mdh_centerX;      ///<< self.center.x
@property (nonatomic) CGFloat mdh_centerY;      ///<< self.center.y

@property (readonly) CGFloat mdh_maxY;         ///<< get CGRectGetMaxY
@property (readonly) CGFloat mdh_minY;         ///<< get CGRectGetMinY
@property (readonly) CGFloat mdh_maxX;         ///<< get CGRectGetMaxX
@property (readonly) CGFloat mdh_minX;         ///<< get CGRectGetMinX

@property (readonly) UIView *mdh_sibling;      //兄弟视图
@property (readonly) UIViewController *mdh_viewController;  //self Responder UIViewControler

// iPhoneX adapt

@property (readonly) CGFloat mdh_safeAreaBottomGap;
@property (readonly) CGFloat mdh_safeAreaTopGap;
@property (readonly) CGFloat mdh_safeAreaLeftGap;
@property (readonly) CGFloat mdh_safeAreaRightGap;

/*
   示例链接编程
   self.mdh_width(100).mdh_height(100).mdh_left(10).mdh_top(10)
*/
- (UIView * (^)(CGFloat top))mdh_top;            ///< set frame y
- (UIView * (^)(CGFloat bottom))mdh_bottom;      ///< set frame y
- (UIView * (^)(CGFloat right))mdh_flexToBottom; ///< set frame height
- (UIView * (^)(CGFloat left))mdh_left;          ///< set frame x
- (UIView * (^)(CGFloat right))mdh_right;        ///< set frame x
- (UIView * (^)(CGFloat right))mdh_flexToRight;  ///< set frame width
- (UIView * (^)(CGFloat width))mdh_width;        ///< set frame width
- (UIView * (^)(CGFloat height))mdh_height;      ///< set frame height
- (UIView * (^)(CGFloat x))mdh__centerX;         ///< set center
- (UIView * (^)(CGFloat y))mdh__centerY;         ///< set center

/*
 相对父View
 */
- (UIView * (^)(void))mdh_center;                 ///< 居中
- (UIView * (^)(void))mdh_fill;                   ///< 填充

/*
 相对与兄弟节点，线性布局
 */
- (UIView * (^)(CGFloat space))mdh_hstack;        ///< 水平，居中对齐
- (UIView * (^)(CGFloat space))mdh_vstack;        ///< 垂直，居中对齐


- (UIView * (^)(void))mdh_sizeToFit;              ///< sizeToFit
- (UIView * (^)(CGFloat w, CGFloat h))mdh_sizeToFitThan;  ///< sizeToFit, 最小值

@end
